<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>background</title>
	<script src="js/jquery.js"></script>
    <link href="js/bootstrap.min.css" rel="stylesheet">
    <link href="js/style.css" rel="stylesheet" type="text/css">
    <script src="js/bootstrap.min.js"></script>
</head>

<body style="margin:0;pading:0;">
<?php
include_once 'conn_mysql.php';
include_once 'sidebar.php';

include_once("function.php");

//excel下载
$url="javascript:alert('请将(正常搜索)选为(excel生成)，再点击搜索，即可点击下载');";
if($_REQUEST['down_print']==2)
{
$url=$_SESSION['excel_url']?$_SESSION['excel_url']:"javascript:void(0)";
}


$bigtype=$_REQUEST['bigtype'];
if(strlen($bigtype)==0){
	$bigtype=1;
}
if($bigtype==1){
?>

<a href="<?php echo $url?>" target="_blank" id="excel_file">
	<input style="margin-top:20px;margin-right:10%;float:right;width:180px;height:30px;border-radius:2px;background-color:#DA4713;color:#FFFFFF;font-family:微软雅黑;font-size:14px;border:1px #000;text-align:center; cursor:pointer;-webkit-appearance:none;" value="excel下载"></input>
</a>
<input style="margin-top:20px;margin-right:10px;float:right;width:180px;height:30px;border-radius:2px;background-color:#DA4713;color:#FFFFFF;font-family:微软雅黑;font-size:14px;border:1px #000;text-align:center; cursor:pointer;-webkit-appearance:none;" onClick="check_order();" value="检测过期订单"></input>

<input type="button" style="float:right;width:80px;height:30px;border-radius:2px;background-color:#DA4713;color:#FFFFFF;font-family:微软雅黑;font-size:14px;border:1px #000;text-align:center; cursor:pointer;margin-top:20px;margin-right:10px;-webkit-appearance:none;" value="搜索" onClick="shoushuo();" ></input>
<select style="float:right;width:120px;height:30px;border-radius:2px;color:#000000;font-family:微软雅黑;font-size:14px;padding-left:13px;border:1px solid #C9CACA;margin-top:20px;margin-right:2%;" id="down_print">
	<option value ="1">正常搜索</option>
	<option value ="2">excel生成</option>
</select>
<select style="float:right;width:120px;height:30px;border-radius:2px;color:#000000;font-family:微软雅黑;font-size:14px;padding-left:13px;border:1px solid #C9CACA;margin-top:20px;margin-right:2%;" id="banqi">
	<option value ="">全部班期</option>
</select>
<select style="float:right;width:135px;height:30px;border-radius:2px;color:#000000;font-family:微软雅黑;font-size:14px;border:1px solid #C9CACA;margin-top:20px;margin-right:2%;" id="xiangmu" onChange="have_banqi()">
	<option value ="">全部线路</option>
</select>
<select style="float:right;width:135px;height:30px;border-radius:2px;color:#000000;font-family:微软雅黑;font-size:14px;border:1px solid #C9CACA;margin-top:20px;margin-right:2%;" id="is_zhifu">
	<option value ="">全部支付状态</option>
	<option value ="0">未支付</option>
	<option value ="1">已支付</option>
	<option value ="2">已取消</option>
</select>
<select style="float:right;width:120px;height:30px;border-radius:2px;color:#000000;font-family:微软雅黑;font-size:14px;padding-left:13px;border:1px solid #C9CACA;margin-top:20px;margin-right:2%;" id="time">
	<option value ="0">全部时间</option>
	<option value ="1">一年以内</option>
</select>


<script type="text/javascript">

//是否废弃超时1小时的未支付订单
function check_order()
{
	if(confirm('是否废弃超时1小时的未支付订单'))
	{
			location.href="http://haining.365jinbi.com/lvxingtianxia/Admin/function_deal.php?fun_1=1";	
	}

}

function fnSaveForm(){
	//设置项目 班期 select框 选择内容
	<?php 
	$sql="SELECT * FROM `lvyou_difang_info` WHERE 1";
	$query = mysql_query($sql);
	while($row = mysql_fetch_array($query)){
	?>
		$("#xiangmu").append("<option value='"+"<?php echo $row['id'];?>"+"'>"+"<?php echo cut_biaoti($row['biaoti'],16);?>"+"</option>");
	<?php
	}
	?>
	
	//班期设置
	<?php 
	if(strlen($xiangmu)!=0){
		$sql="SELECT * FROM `lvyou_difang_info` WHERE id='$xiangmu'";
		$query = mysql_query($sql);
		while($row = mysql_fetch_array($query)){
			$banqi1=$row['banqi1'];
			$banqi2=$row['banqi2'];
			$banqi3=$row['banqi3'];
		}
	}
	?>
	<?php if(strlen($banqi1)!=0){?>
	$("#banqi").append("<option value='"+"<?php echo $banqi1;?>"+"'>"+"<?php echo $banqi1;?>"+"</option>");
	<?php }?>
	<?php if(strlen($banqi2)!=0){?>
	$("#banqi").append("<option value='"+"<?php echo $banqi2;?>"+"'>"+"<?php echo $banqi2;?>"+"</option>");
	<?php }?>
	<?php if(strlen($banqi3)!=0){?>
	$("#banqi").append("<option value='"+"<?php echo $banqi3;?>"+"'>"+"<?php echo $banqi3;?>"+"</option>");
	<?php }?>
	
	var selectObj=document.getElementById("time");
	for (i=0; i< selectObj.options.length; i++){
		var curOptObj=selectObj.options[i];
		var curText=curOptObj.value;
		if("<?php echo $time;?>"==curText){
			curOptObj.selected=true;
		}
	}
	var selectObj=document.getElementById("banqi");
	for (i=0; i< selectObj.options.length; i++){
		var curOptObj=selectObj.options[i];
		var curText=curOptObj.value;
		if("<?php echo $banqi;?>"==curText){
			curOptObj.selected=true;
		}
	}
	var selectObj=document.getElementById("xiangmu");
	for (i=0; i< selectObj.options.length; i++){
		var curOptObj=selectObj.options[i];
		var curText=curOptObj.value;
		if("<?php echo $xiangmu;?>"==curText){
			curOptObj.selected=true;
		}
	}
	var selectObj=document.getElementById("is_zhifu");
	for (i=0; i< selectObj.options.length; i++){
		var curOptObj=selectObj.options[i];
		var curText=curOptObj.value;
		if("<?php echo $is_zhifu;?>"==curText){
			curOptObj.selected=true;
		}
	}
		var selectObj=document.getElementById("down_print");
	for (i=0; i< selectObj.options.length; i++){
		var curOptObj=selectObj.options[i];
		var curText=curOptObj.value;
		if("<?php echo $_REQUEST['down_print'];?>"==curText){
			curOptObj.selected=true;
		}
	}
}
window.onload=fnSaveForm;

function have_banqi(){
	xiangmu=document.getElementById("xiangmu").value;
	
	//获取班期
	var url="getmessage_all.php?bigtype=26";
	url=url+"&xiangmu="+xiangmu;
	$.ajax({
		type:"GET",
		url:url,
		dataType: "json",
		success: function(data){	
			if(data['code']==0001){
				$("#banqi").empty(); 
				$("#banqi").append("<option value='"+data['banqi1']+"'>"+data['banqi1']+"</option>");
				$("#banqi").append("<option value='"+data['banqi2']+"'>"+data['banqi2']+"</option>");
				$("#banqi").append("<option value='"+data['banqi3']+"'>"+data['banqi3']+"</option>");
			}
		}
	}); 	
	
}

function shoushuo(){
	time=document.getElementById("time").value;
	xiangmu=document.getElementById("xiangmu").value;
	banqi=document.getElementById("banqi").value;
	is_zhifu=document.getElementById("is_zhifu").value;
	down_print=document.getElementById("down_print").value;
		var where_str='';
	if(down_print==2)where_str="&down_print=2";
	//跳转到后台，用session记录下它们
	window.location.href='getmessage_all.php?bigtype=25&time='+time+'&xiangmu='+xiangmu+'&banqi='+banqi+'&is_zhifu='+is_zhifu+where_str;
}

</script>
<div style="clear:right;width:80%;height:40px;margin-left:200px;margin-top:5px;border-bottom:1.5px solid #C9C9CA;">	
	<div style="clear:right;float:left;width:8%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;">序号</a></div>
	<div style="clear:right;float:left;width:11%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;">姓名</a></div>
	<div style="clear:right;float:left;width:11%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;">电话</a></div>
	<div style="clear:right;float:left;width:15%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;">报名的旅游项目</a></div>
	<div style="clear:right;float:left;width:11%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;">班期</a></div>
	<div style="clear:right;float:left;width:11%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;">报名时间</a></div>
	<div style="clear:right;float:left;width:12%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;">所需支付金额</a></div>
	<div style="clear:right;float:left;width:10%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;">支付状态</a></div>
	<div style="clear:right;float:left;width:10%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;">操作</a></div>
</div>
<?php
//拼装筛选sql
if(strlen($xiangmu)==0 and strlen($banqi)==0 and strlen($time)==0){
	$sql="select * from  main_user where 1";
}
if(strlen($xiangmu)==0 and strlen($banqi)==0 and strlen($time)!=0){
	$sql="select * from  main_user where TIMESTAMPDIFF(day,issuetime,now())<365";
}
if(strlen($xiangmu)==0 and strlen($banqi)!=0 and strlen($time)==0){
	$sql="select * from  main_user where banqi='$banqi'";
}
if(strlen($xiangmu)==0 and strlen($banqi)!=0 and strlen($time)!=0){
	$sql="select * from  main_user where banqi='$banqi' and TIMESTAMPDIFF(day,issuetime,now())<365 ";
}
if(strlen($xiangmu)!=0 and strlen($banqi)==0 and strlen($time)==0){
	$sql="select * from  main_user where id_difang='$xiangmu'";
}
if(strlen($xiangmu)!=0 and strlen($banqi)==0 and strlen($time)!=0){
	$sql="select * from  main_user where id_difang='$xiangmu' and TIMESTAMPDIFF(day,issuetime,now())<365 ";
}
if(strlen($xiangmu)!=0 and strlen($banqi)!=0 and strlen($time)==0){
	$sql="select * from  main_user where id_difang='$xiangmu' and banqi='$banqi' order by id_self desc";
}
if(strlen($xiangmu)!=0 and strlen($banqi)!=0 and strlen($time)!=0){
	$sql="select * from  main_user where id_difang='$xiangmu' and banqi='$banqi' and TIMESTAMPDIFF(day,issuetime,now())<365 ";
}
//多加支付筛选
if($is_zhifu=='0'){
	$sql=$sql." and is_zhifu='0'";
}
if($is_zhifu=='1'){
	$sql=$sql." and is_zhifu='1'";
}
if($is_zhifu=='2'){
	$sql=$sql." and is_zhifu='2'";
}
//echo $sql;

$sql.=" order by id_self desc";
$query = mysql_query($sql);
$num=mysql_num_rows($query);

$pag=$_REQUEST['pag'];
if($pag>ceil($num/10)){
	$pag=ceil($num/10);
}
if($pag<1){
	$pag=1;
}

$pag_bigin=($pag-1)*10;

$i=1+$pag_bigin;

if($_REQUEST['down_print']==2)
{
	include_once 'print_order.php';


    $mes=print_excel($sql);
    $url=$_SESSION['excel_url']?$_SESSION['excel_url']:"javascript:void(0)";
    echo "<script>alert('$mes');var excel_file=document.getElementById('excel_file');excel_file.href='$url';</script>";

    
}



//跳转链接
$page_url="dingdan_info.php?info_type=3&phone=$phone&user_ID=$user_ID&birthday=$birthday";
/*分页*/
$page_list=get_html_page_list($pag,10,$num);

$sql=$sql." limit $pag_bigin,10";
$query = mysql_query($sql);

// $no_number=$i-1;
while($row = mysql_fetch_array($query)){

	// $no_number++;
	//查询用户姓名 电话
	$sql1="select * from `ecs_users` where openid='".$row['openid']."'";
	$query1 = mysql_query($sql1);
	while($row1 = mysql_fetch_array($query1)){
		$user_name=$row1['user_name'];
		$mobile_phone=$row1['mobile_phone'];
	}
	//查询报名的旅游线路名
	$sql1="select * from `lvyou_difang_info` where id='".$row['id_difang']."'";
	$query1 = mysql_query($sql1);
	while($row1 = mysql_fetch_array($query1)){
		$biaoti=$row1['biaoti'];
	}
	//获取支付状态 0未支付 1-已支付 2-已取消
	if($row['is_zhifu']==0){
		$is_zhifu="未支付";
	}
	if($row['is_zhifu']==1){
		$is_zhifu="已支付";
	}
	if($row['is_zhifu']==2){
		$is_zhifu="已取消";
	}
?>
<div style="width:80%;height:40px;margin-left:200px;margin-top:5px;border-bottom:1px solid #C9C9CA;">	
	<div style="clear:right;float:left;width:8%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;"><?php echo $row['id_self'];?></a></div>
	<div style="float:left;width:11%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;"><?php echo $user_name;?></a></div>
	<div style="float:left;width:11%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;"><?php echo $mobile_phone;?></a></div>
	<div style="float:left;width:15%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;"><?php echo cut_biaoti($biaoti,16);?></a></div>
	<div style="float:left;width:11%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;"><?php echo $row['banqi'];?></a></div>
	<div style="float:left;width:12%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;"><?php echo $row['issuetime'];?></a></div>
	
	<div style="float:left;width:11%;height:40px;line-height:40px;text-align:center;"><a style="color:#3E3A39;font-family:微软雅黑;font-size:14px;">
		<?php
		 $pay_points=$row['pay_points'];
		echo $row['zhifu_monkey']."元";
		if($pay_points>0)
	    echo "(使用驴币".$pay_points.")";?></a></div>
	<div style="float:left;width:10%;height:40px;line-height:40px;text-align:center;"><a style="color:#DA4B3B;font-family:微软雅黑;font-size:14px;cursor:pointer;" onClick="xiugei_zhifuzhuangtai('<?php echo $row['id_self'];?>');">
		<?php echo $is_zhifu;?>
	</a></div>
	
    <div style="float:left;width:5%;height:40px;line-height:40px;text-align:center;"><a style="color:#DA4B3B;font-family:微软雅黑;font-size:14px;cursor:pointer;" href="dingdan_detail.php?id_self=<?php echo $row['id_self'];?>"><?php echo "详情";?></a></div>
    <div style="float:left;width:5%;height:40px;line-height:40px;text-align:center;"><a style="color:#DA4B3B;font-family:微软雅黑;font-size:14px;cursor:pointer;" onClick="dell_dingdan('<?php echo $row['id_self'];?>')"><?php echo "删除";?></a></div>
</div>
<?php } ?>

<?php } ?>

</div>
<div style="width:90%;height:35px;text-align:center;line-height:35px;margin-top:15px;margin-left: 50px;">
        	<a style="display:inline;color:#DA4B3B;font-family:微软雅黑;font-size:14px;text-decoration:none;cursor:pointer;" href="<?php echo  $page_url."&pag=".$page_list['first']['page']; ?>">首页</a>
			<a style="display:inline;color:#DA4B3B;font-family:微软雅黑;font-size:14px;text-decoration:none;cursor:pointer;" href="<?php echo  $page_url."&pag=".$page_list['front']['page']; ?>">上一页</a>
			<a style="display:inline;color:#3E3A39;font-family:微软雅黑;font-size:14px;margin-left:10px;"><</a>
			<?php
			foreach($page_list['list'] as $k_page=>$v_page){
				if($v_page['page']==$pag){
			?>
				<a style="display:inline;color:#DA4B3B;font-family:微软雅黑;font-size:14px;text-decoration:none;cursor:pointer;" href="<?php echo $page_url."&pag=".$v_page['page']; ?>"><?php echo $v_page['page'] ?></a>
				<?php }else{ ?>
				<a style="display:inline;color:#3E3A39;font-family:微软雅黑;font-size:14px;text-decoration:none;cursor:pointer;" href="<?php echo $page_url."&pag=".$v_page['page']; ?>"><?php echo $v_page['page'] ?></a>
				<?php }
				} ?>
                
			<a style="display:inline;color:#3E3A39;font-family:微软雅黑;font-size:14px;">></a><a style="display:inline;color:#DA4B3B;font-family:微软雅黑;font-size:14px;margin-left:10px;text-decoration:none;cursor:pointer;" href="<?php echo $page_url."&pag=".$page_list['after']['page'];  ?>">下一页</a>
            <a style="display:inline;color:#DA4B3B;font-family:微软雅黑;font-size:14px;text-decoration:none;cursor:pointer;" href="<?php echo $page_url."&pag=".$page_list['last']['page'];  ?>">尾页</a>
		     <span style="display:inline;color:#DA4B3B;font-family:微软雅黑;font-size:14px;margin-left:10px;text-decoration:none;cursor:pointer;" href="javascript:void(0)">总计<?php echo $page_list['last']['page']; ?>页</span>
        </div>


<script type="text/javascript">
function dell_dingdan(id){
	if (confirm("是否确认删除该订单")){  
		window.location.href="getmessage_all.php?bigtype=27&id="+id;
	}
}

function xiugei_zhifuzhuangtai(id){
	var zhifu_zhuangtai=prompt("请输入要修改的订单状态。如未支付，已支付，已取消。","");
	if(zhifu_zhuangtai!="未支付" && zhifu_zhuangtai!="已支付" && zhifu_zhuangtai!="已取消" ){
		alert("输入的状态不符合规定格式，此次修改不生效！");
		return 0;
	}
	if(zhifu_zhuangtai=="未支付"){
		zhifu_zhuangtai=0;
	}
	if(zhifu_zhuangtai=="已支付"){
		zhifu_zhuangtai=1;
	}
	if(zhifu_zhuangtai=="已取消"){
		zhifu_zhuangtai=2;
	}
	window.location.href="getmessage_all.php?bigtype=28&id="+id+'&zhifu_zhuangtai='+zhifu_zhuangtai;
}
</script>
<?php
function cut_biaoti($string, $length) {
    preg_match_all("/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/", $string, $info);
    for($i=0; $i<count($info[0]); $i++) {
        $wordscut .= $info[0][$i];
        $j = ord($info[0][$i]) > 127 ? $j + 2 : $j + 1;
        if ($j > $length - 3) {
            return $wordscut;
        }
    }
    return join('', $info[0]);
}
?>



